home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / src / gcc-2.7.0-amiga / c-parse.y < prev    next >
GNU Bison Grammar  |  1995-06-15  |  62KB  |  2,059 lines

  1. /* YACC parser for C syntax and for Objective C.  -*-c-*-
  2.    Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. /* This file defines the grammar of C and that of Objective C.
  22.    ifobjc ... end ifobjc  conditionals contain code for Objective C only.
  23.    ifc ... end ifc  conditionals contain code for C only.
  24.    Sed commands in Makefile.in are used to convert this file into
  25.    c-parse.y and into objc-parse.y.  */
  26.  
  27. /* To whomever it may concern: I have heard that such a thing was once
  28.    written by AT&T, but I have never seen it.  */
  29.  
  30. %expect 34
  31.  
  32. /* These are the 23 conflicts you should get in parse.output;
  33.    the state numbers may vary if minor changes in the grammar are made.
  34.  
  35. State 42 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
  36. State 44 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  37. State 103 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  38. State 110 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
  39. State 111 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  40. State 115 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  41. State 132 contains 1 shift/reduce conflict.  (See comment at component_decl.)
  42. State 180 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
  43. State 194 contains 2 shift/reduce conflict.  (Four ways to parse this.)
  44. State 202 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  45. State 214 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  46. State 220 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  47. State 304 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
  48. State 335 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
  49. State 347 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTES.)
  50. State 352 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTES.)
  51. State 383 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
  52. State 434 contains 2 shift/reduce conflicts.  (Four ways to parse this.)  */
  53.  
  54.  
  55. %{
  56. #include <stdio.h>
  57. #include <errno.h>
  58. #include <setjmp.h>
  59.  
  60. #include "config.h"
  61. #include "tree.h"
  62. #include "input.h"
  63. #include "c-lex.h"
  64. #include "c-tree.h"
  65. #include "flags.h"
  66.  
  67. #ifdef MULTIBYTE_CHARS
  68. #include <stdlib.h>
  69. #include <locale.h>
  70. #endif
  71.  
  72.  
  73. /* Since parsers are distinct for each language, put the language string
  74.    definition here.  */
  75. char *language_string = "GNU C";
  76.  
  77. #ifndef errno
  78. extern int errno;
  79. #endif
  80.  
  81. void yyerror ();
  82.  
  83. /* Like YYERROR but do call yyerror.  */
  84. #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  85.  
  86. /* Cause the `yydebug' variable to be defined.  */
  87. #define YYDEBUG 1
  88. %}
  89.  
  90. %start program
  91.  
  92. %union {long itype; tree ttype; enum tree_code code;
  93.     char *filename; int lineno; }
  94.  
  95. /* All identifiers that are not reserved words
  96.    and are not declared typedefs in the current block */
  97. %token IDENTIFIER
  98.  
  99. /* All identifiers that are declared typedefs in the current block.
  100.    In some contexts, they are treated just like IDENTIFIER,
  101.    but they can also serve as typespecs in declarations.  */
  102. %token TYPENAME
  103.  
  104. /* Reserved words that specify storage class.
  105.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  106. %token SCSPEC
  107.  
  108. /* Reserved words that specify type.
  109.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  110. %token TYPESPEC
  111.  
  112. /* Reserved words that qualify type: "const" or "volatile".
  113.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  114. %token TYPE_QUAL
  115.  
  116. /* Character or numeric constants.
  117.    yylval is the node for the constant.  */
  118. %token CONSTANT
  119.  
  120. /* String constants in raw form.
  121.    yylval is a STRING_CST node.  */
  122. %token STRING
  123.  
  124. /* "...", used for functions with variable arglists.  */
  125. %token ELLIPSIS
  126.  
  127. /* the reserved words */
  128. /* SCO include files test "ASM", so use something else. */
  129. %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
  130. %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
  131. %token ATTRIBUTE EXTENSION LABEL
  132. %token REALPART IMAGPART
  133.  
  134. /* Add precedence rules to solve dangling else s/r conflict */
  135. %nonassoc IF
  136. %nonassoc ELSE
  137.  
  138. /* Define the operator tokens and their precedences.
  139.    The value is an integer because, if used, it is the tree code
  140.    to use in the expression made from the operator.  */
  141.  
  142. %right <code> ASSIGN '='
  143. %right <code> '?' ':'
  144. %left <code> OROR
  145. %left <code> ANDAND
  146. %left <code> '|'
  147. %left <code> '^'
  148. %left <code> '&'
  149. %left <code> EQCOMPARE
  150. %left <code> ARITHCOMPARE
  151. %left <code> LSHIFT RSHIFT
  152. %left <code> '+' '-'
  153. %left <code> '*' '/' '%'
  154. %right <code> UNARY PLUSPLUS MINUSMINUS
  155. %left HYPERUNARY
  156. %left <code> POINTSAT '.' '(' '['
  157.  
  158. /* The Objective-C keywords.  These are included in C and in
  159.    Objective C, so that the token codes are the same in both.  */
  160. %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
  161. %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
  162.  
  163. /* Objective-C string constants in raw form.
  164.    yylval is an OBJC_STRING_CST node.  */
  165. %token OBJC_STRING
  166.  
  167.  
  168. %type <code> unop
  169.  
  170. %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
  171. %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
  172. %type <ttype> typed_declspecs reserved_declspecs
  173. %type <ttype> typed_typespecs reserved_typespecquals
  174. %type <ttype> declmods typespec typespecqual_reserved
  175. %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
  176. %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
  177. %type <ttype> init maybeasm
  178. %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
  179. %type <ttype> maybe_attribute attributes attribute attribute_list attrib
  180. %type <ttype> any_word
  181.  
  182. %type <ttype> compstmt
  183.  
  184. %type <ttype> declarator
  185. %type <ttype> notype_declarator after_type_declarator
  186. %type <ttype> parm_declarator
  187.  
  188. %type <ttype> structsp component_decl_list component_decl_list2
  189. %type <ttype> component_decl components component_declarator
  190. %type <ttype> enumlist enumerator
  191. %type <ttype> typename absdcl absdcl1 type_quals
  192. %type <ttype> xexpr parms parm identifiers
  193.  
  194. %type <ttype> parmlist parmlist_1 parmlist_2
  195. %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
  196. %type <ttype> identifiers_or_typenames
  197.  
  198. %type <itype> setspecs
  199.  
  200. %type <filename> save_filename
  201. %type <lineno> save_lineno
  202.  
  203.  
  204. %{
  205. /* Number of statements (loosely speaking) seen so far.  */
  206. static int stmt_count;
  207.  
  208. /* Input file and line number of the end of the body of last simple_if;
  209.    used by the stmt-rule immediately after simple_if returns.  */
  210. static char *if_stmt_file;
  211. static int if_stmt_line;
  212.  
  213. /* List of types and structure classes of the current declaration.  */
  214. static tree current_declspecs;
  215. static tree prefix_attributes = NULL_TREE;
  216.  
  217. /* Stack of saved values of current_declspecs and prefix_attributes.  */
  218. static tree declspec_stack;
  219.  
  220. /* 1 if we explained undeclared var errors.  */
  221. static int undeclared_variable_notice;
  222.  
  223.  
  224. /* Tell yyparse how to print a token's value, if yydebug is set.  */
  225.  
  226. #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
  227. extern void yyprint ();
  228. %}
  229.  
  230. %%
  231. program: /* empty */
  232.         { if (pedantic)
  233.             pedwarn ("ANSI C forbids an empty source file");
  234.           finish_file ();
  235.         }
  236.     | extdefs
  237.         {
  238.           /* In case there were missing closebraces,
  239.              get us back to the global binding level.  */
  240.           while (! global_bindings_p ())
  241.             poplevel (0, 0, 0);
  242.           finish_file ();
  243.         }
  244.     ;
  245.  
  246. /* the reason for the strange actions in this rule
  247.  is so that notype_initdecls when reached via datadef
  248.  can find a valid list of type and sc specs in $0. */
  249.  
  250. extdefs:
  251.     {$<ttype>$ = NULL_TREE; } extdef
  252.     | extdefs {$<ttype>$ = NULL_TREE; } extdef
  253.     ;
  254.  
  255. extdef:
  256.     fndef
  257.     | datadef
  258.     | ASM_KEYWORD '(' expr ')' ';'
  259.         { STRIP_NOPS ($3);
  260.           if ((TREE_CODE ($3) == ADDR_EXPR
  261.                && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
  262.               || TREE_CODE ($3) == STRING_CST)
  263.             assemble_asm ($3);
  264.           else
  265.             error ("argument of `asm' is not a constant string"); }
  266.     ;
  267.  
  268. datadef:
  269.       setspecs notype_initdecls ';'
  270.         { if (pedantic)
  271.             error ("ANSI C forbids data definition with no type or storage class");
  272.           else if (!flag_traditional)
  273.             warning ("data definition has no type or storage class"); 
  274.  
  275.           current_declspecs = TREE_VALUE (declspec_stack);
  276.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  277.           declspec_stack = TREE_CHAIN (declspec_stack);
  278.           resume_momentary ($1); }
  279.         | declmods setspecs notype_initdecls ';'
  280.         { current_declspecs = TREE_VALUE (declspec_stack);
  281.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  282.           declspec_stack = TREE_CHAIN (declspec_stack);
  283.           resume_momentary ($2); }
  284.     | typed_declspecs setspecs initdecls ';'
  285.         { current_declspecs = TREE_VALUE (declspec_stack);
  286.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  287.           declspec_stack = TREE_CHAIN (declspec_stack);
  288.           resume_momentary ($2);  }
  289.         | declmods ';'
  290.       { pedwarn ("empty declaration"); }
  291.     | typed_declspecs ';'
  292.       { shadow_tag ($1); }
  293.     | error ';'
  294.     | error '}'
  295.     | ';'
  296.         { if (pedantic)
  297.             pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
  298.     ;
  299.  
  300. fndef:
  301.       typed_declspecs setspecs declarator
  302.         { if (! start_function ($1, $3, prefix_attributes,
  303.                     NULL_TREE, 0))
  304.             YYERROR1;
  305.           reinit_parse_for_function (); }
  306.       xdecls
  307.         { store_parm_decls (); }
  308.       compstmt_or_error
  309.         { finish_function (0); 
  310.           current_declspecs = TREE_VALUE (declspec_stack);
  311.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  312.           declspec_stack = TREE_CHAIN (declspec_stack);
  313.           resume_momentary ($2); }
  314.     | typed_declspecs setspecs declarator error
  315.         { current_declspecs = TREE_VALUE (declspec_stack);
  316.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  317.           declspec_stack = TREE_CHAIN (declspec_stack);
  318.           resume_momentary ($2); }
  319.     | declmods setspecs notype_declarator
  320.         { if (! start_function ($1, $3, prefix_attributes,
  321.                     NULL_TREE, 0))
  322.             YYERROR1;
  323.           reinit_parse_for_function (); }
  324.       xdecls
  325.         { store_parm_decls (); }
  326.       compstmt_or_error
  327.         { finish_function (0); 
  328.           current_declspecs = TREE_VALUE (declspec_stack);
  329.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  330.           declspec_stack = TREE_CHAIN (declspec_stack);
  331.           resume_momentary ($2); }
  332.     | declmods setspecs notype_declarator error
  333.         { current_declspecs = TREE_VALUE (declspec_stack);
  334.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  335.           declspec_stack = TREE_CHAIN (declspec_stack);
  336.           resume_momentary ($2); }
  337.     | setspecs notype_declarator
  338.         { if (! start_function (NULL_TREE, $2,
  339.                     prefix_attributes, NULL_TREE, 0))
  340.             YYERROR1;
  341.           reinit_parse_for_function (); }
  342.       xdecls
  343.         { store_parm_decls (); }
  344.       compstmt_or_error
  345.         { finish_function (0); 
  346.           current_declspecs = TREE_VALUE (declspec_stack);
  347.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  348.           declspec_stack = TREE_CHAIN (declspec_stack);
  349.           resume_momentary ($1); }
  350.     | setspecs notype_declarator error
  351.         { current_declspecs = TREE_VALUE (declspec_stack);
  352.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  353.           declspec_stack = TREE_CHAIN (declspec_stack);
  354.           resume_momentary ($1); }
  355.     ;
  356.  
  357. identifier:
  358.     IDENTIFIER
  359.     | TYPENAME
  360.     ;
  361.  
  362. unop:     '&'
  363.         { $$ = ADDR_EXPR; }
  364.     | '-'
  365.         { $$ = NEGATE_EXPR; }
  366.     | '+'
  367.         { $$ = CONVERT_EXPR; }
  368.     | PLUSPLUS
  369.         { $$ = PREINCREMENT_EXPR; }
  370.     | MINUSMINUS
  371.         { $$ = PREDECREMENT_EXPR; }
  372.     | '~'
  373.         { $$ = BIT_NOT_EXPR; }
  374.     | '!'
  375.         { $$ = TRUTH_NOT_EXPR; }
  376.     ;
  377.  
  378. expr:    nonnull_exprlist
  379.         { $$ = build_compound_expr ($1); }
  380.     ;
  381.  
  382. exprlist:
  383.       /* empty */
  384.         { $$ = NULL_TREE; }
  385.     | nonnull_exprlist
  386.     ;
  387.  
  388. nonnull_exprlist:
  389.     expr_no_commas
  390.         { $$ = build_tree_list (NULL_TREE, $1); }
  391.     | nonnull_exprlist ',' expr_no_commas
  392.         { chainon ($1, build_tree_list (NULL_TREE, $3)); }
  393.     ;
  394.  
  395. unary_expr:
  396.     primary
  397.     | '*' cast_expr   %prec UNARY
  398.         { $$ = build_indirect_ref ($2, "unary *"); }
  399.     /* __extension__ turns off -pedantic for following primary.  */
  400.     | EXTENSION
  401.         { $<itype>1 = pedantic;
  402.           pedantic = 0; }
  403.       cast_expr      %prec UNARY
  404.         { $$ = $3;
  405.           pedantic = $<itype>1; }
  406.     | unop cast_expr  %prec UNARY
  407.         { $$ = build_unary_op ($1, $2, 0);
  408.           overflow_warning ($$); }
  409.     /* Refer to the address of a label as a pointer.  */
  410.     | ANDAND identifier
  411.         { tree label = lookup_label ($2);
  412.           if (pedantic)
  413.             pedwarn ("ANSI C forbids `&&'");
  414.           if (label == 0)
  415.             $$ = null_pointer_node;
  416.           else
  417.             {
  418.               TREE_USED (label) = 1;
  419.               $$ = build1 (ADDR_EXPR, ptr_type_node, label);
  420.               TREE_CONSTANT ($$) = 1;
  421.             }
  422.         }
  423. /* This seems to be impossible on some machines, so let's turn it off.
  424.    You can use __builtin_next_arg to find the anonymous stack args.
  425.     | '&' ELLIPSIS
  426.         { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
  427.           $$ = error_mark_node;
  428.           if (TREE_VALUE (tree_last (types)) == void_type_node)
  429.             error ("`&...' used in function with fixed number of arguments");
  430.           else
  431.             {
  432.               if (pedantic)
  433.             pedwarn ("ANSI C forbids `&...'");
  434.               $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
  435.               $$ = build_unary_op (ADDR_EXPR, $$, 0);
  436.             } }
  437. */
  438.     | SIZEOF unary_expr  %prec UNARY
  439.         { if (TREE_CODE ($2) == COMPONENT_REF
  440.               && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
  441.             error ("`sizeof' applied to a bit-field");
  442.           $$ = c_sizeof (TREE_TYPE ($2)); }
  443.     | SIZEOF '(' typename ')'  %prec HYPERUNARY
  444.         { $$ = c_sizeof (groktypename ($3)); }
  445.     | ALIGNOF unary_expr  %prec UNARY
  446.         { $$ = c_alignof_expr ($2); }
  447.     | ALIGNOF '(' typename ')'  %prec HYPERUNARY
  448.         { $$ = c_alignof (groktypename ($3)); }
  449.     | REALPART cast_expr %prec UNARY
  450.         { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
  451.     | IMAGPART cast_expr %prec UNARY
  452.         { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
  453.     ;
  454.  
  455. cast_expr:
  456.     unary_expr
  457.     | '(' typename ')' cast_expr  %prec UNARY
  458.         { tree type = groktypename ($2);
  459.           $$ = build_c_cast (type, $4); }
  460.     | '(' typename ')' '{' 
  461.         { start_init (NULL_TREE, NULL, 0);
  462.           $2 = groktypename ($2);
  463.           really_start_incremental_init ($2); }
  464.       initlist_maybe_comma '}'  %prec UNARY
  465.         { char *name;
  466.           tree result = pop_init_level (0);
  467.           tree type = $2;
  468.           finish_init ();
  469.  
  470.           if (pedantic)
  471.             pedwarn ("ANSI C forbids constructor expressions");
  472.           if (TYPE_NAME (type) != 0)
  473.             {
  474.               if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  475.             name = IDENTIFIER_POINTER (TYPE_NAME (type));
  476.               else
  477.             name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
  478.             }
  479.           else
  480.             name = "";
  481.           $$ = result;
  482.           if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
  483.             {
  484.               int failure = complete_array_type (type, $$, 1);
  485.               if (failure)
  486.             abort ();
  487.             }
  488.         }
  489.     ;
  490.  
  491. expr_no_commas:
  492.       cast_expr
  493.     | expr_no_commas '+' expr_no_commas
  494.         { $$ = parser_build_binary_op ($2, $1, $3); }
  495.     | expr_no_commas '-' expr_no_commas
  496.         { $$ = parser_build_binary_op ($2, $1, $3); }
  497.     | expr_no_commas '*' expr_no_commas
  498.         { $$ = parser_build_binary_op ($2, $1, $3); }
  499.     | expr_no_commas '/' expr_no_commas
  500.         { $$ = parser_build_binary_op ($2, $1, $3); }
  501.     | expr_no_commas '%' expr_no_commas
  502.         { $$ = parser_build_binary_op ($2, $1, $3); }
  503.     | expr_no_commas LSHIFT expr_no_commas
  504.         { $$ = parser_build_binary_op ($2, $1, $3); }
  505.     | expr_no_commas RSHIFT expr_no_commas
  506.         { $$ = parser_build_binary_op ($2, $1, $3); }
  507.     | expr_no_commas ARITHCOMPARE expr_no_commas
  508.         { $$ = parser_build_binary_op ($2, $1, $3); }
  509.     | expr_no_commas EQCOMPARE expr_no_commas
  510.         { $$ = parser_build_binary_op ($2, $1, $3); }
  511.     | expr_no_commas '&' expr_no_commas
  512.         { $$ = parser_build_binary_op ($2, $1, $3); }
  513.     | expr_no_commas '|' expr_no_commas
  514.         { $$ = parser_build_binary_op ($2, $1, $3); }
  515.     | expr_no_commas '^' expr_no_commas
  516.         { $$ = parser_build_binary_op ($2, $1, $3); }
  517.     | expr_no_commas ANDAND expr_no_commas
  518.         { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
  519.     | expr_no_commas OROR expr_no_commas
  520.         { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
  521.     | expr_no_commas '?' xexpr ':' expr_no_commas
  522.         { $$ = build_conditional_expr ($1, $3, $5); }
  523.     | expr_no_commas '=' expr_no_commas
  524.         { $$ = build_modify_expr ($1, NOP_EXPR, $3);
  525.           C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
  526.     | expr_no_commas ASSIGN expr_no_commas
  527.         { $$ = build_modify_expr ($1, $2, $3);
  528.           /* This inhibits warnings in truthvalue_conversion.  */
  529.           C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
  530.     ;
  531.  
  532. primary:
  533.     IDENTIFIER
  534.         {
  535.           $$ = lastiddecl;
  536.           if (!$$ || $$ == error_mark_node)
  537.             {
  538.               if (yychar == YYEMPTY)
  539.             yychar = YYLEX;
  540.               if (yychar == '(')
  541.             {
  542.                 {
  543.                   /* Ordinary implicit function declaration.  */
  544.                   $$ = implicitly_declare ($1);
  545.                   assemble_external ($$);
  546.                   TREE_USED ($$) = 1;
  547.                 }
  548.             }
  549.               else if (current_function_decl == 0)
  550.             {
  551.               error ("`%s' undeclared here (not in a function)",
  552.                  IDENTIFIER_POINTER ($1));
  553.               $$ = error_mark_node;
  554.             }
  555.               else
  556.             {
  557.                 {
  558.                   if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
  559.                   || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
  560.                 {
  561.                   error ("`%s' undeclared (first use this function)",
  562.                      IDENTIFIER_POINTER ($1));
  563.  
  564.                   if (! undeclared_variable_notice)
  565.                     {
  566.                       error ("(Each undeclared identifier is reported only once");
  567.                       error ("for each function it appears in.)");
  568.                       undeclared_variable_notice = 1;
  569.                     }
  570.                 }
  571.                   $$ = error_mark_node;
  572.                   /* Prevent repeated error messages.  */
  573.                   IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
  574.                   IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
  575.                 }
  576.             }
  577.             }
  578.           else if (TREE_TYPE ($$) == error_mark_node)
  579.             $$ = error_mark_node;
  580.           else if (C_DECL_ANTICIPATED ($$))
  581.             {
  582.               /* The first time we see a build-in function used,
  583.              if it has not been declared.  */
  584.               C_DECL_ANTICIPATED ($$) = 0;
  585.               if (yychar == YYEMPTY)
  586.             yychar = YYLEX;
  587.               if (yychar == '(')
  588.             {
  589.               /* Omit the implicit declaration we
  590.                  would ordinarily do, so we don't lose
  591.                  the actual built in type.
  592.                  But print a diagnostic for the mismatch.  */
  593.                 if (TREE_CODE ($$) != FUNCTION_DECL)
  594.                   error ("`%s' implicitly declared as function",
  595.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  596.               else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
  597.                     != TYPE_MODE (integer_type_node))
  598.                    && (TREE_TYPE (TREE_TYPE ($$))
  599.                        != void_type_node))
  600.                 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
  601.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  602.               /* If it really returns void, change that to int.  */
  603.               if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
  604.                 TREE_TYPE ($$)
  605.                   = build_function_type (integer_type_node,
  606.                              TYPE_ARG_TYPES (TREE_TYPE ($$)));
  607.             }
  608.               else
  609.             pedwarn ("built-in function `%s' used without declaration",
  610.                  IDENTIFIER_POINTER (DECL_NAME ($$)));
  611.  
  612.               /* Do what we would ordinarily do when a fn is used.  */
  613.               assemble_external ($$);
  614.               TREE_USED ($$) = 1;
  615.             }
  616.           else
  617.             {
  618.               assemble_external ($$);
  619.               TREE_USED ($$) = 1;
  620.             }
  621.  
  622.           if (TREE_CODE ($$) == CONST_DECL)
  623.             {
  624.               $$ = DECL_INITIAL ($$);
  625.               /* This is to prevent an enum whose value is 0
  626.              from being considered a null pointer constant.  */
  627.               $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
  628.               TREE_CONSTANT ($$) = 1;
  629.             }
  630.         }
  631.     | CONSTANT
  632.     | string
  633.         { $$ = combine_strings ($1); }
  634.     | '(' expr ')'
  635.         { char class = TREE_CODE_CLASS (TREE_CODE ($2));
  636.           if (class == 'e' || class == '1'
  637.               || class == '2' || class == '<')
  638.             C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
  639.           $$ = $2; }
  640.     | '(' error ')'
  641.         { $$ = error_mark_node; }
  642.     | '('
  643.         { if (current_function_decl == 0)
  644.             {
  645.               error ("braced-group within expression allowed only inside a function");
  646.               YYERROR;
  647.             }
  648.           /* We must force a BLOCK for this level
  649.              so that, if it is not expanded later,
  650.              there is a way to turn off the entire subtree of blocks
  651.              that are contained in it.  */
  652.           keep_next_level ();
  653.           push_iterator_stack ();
  654.           push_label_level ();
  655.           $<ttype>$ = expand_start_stmt_expr (); }
  656.       compstmt ')'
  657.         { tree rtl_exp;
  658.           if (pedantic)
  659.             pedwarn ("ANSI C forbids braced-groups within expressions");
  660.           pop_iterator_stack ();
  661.           pop_label_level ();
  662.           rtl_exp = expand_end_stmt_expr ($<ttype>2);
  663.           /* The statements have side effects, so the group does.  */
  664.           TREE_SIDE_EFFECTS (rtl_exp) = 1;
  665.  
  666.           if (TREE_CODE ($3) == BLOCK)
  667.             {
  668.               /* Make a BIND_EXPR for the BLOCK already made.  */
  669.               $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
  670.                   NULL_TREE, rtl_exp, $3);
  671.               /* Remove the block from the tree at this point.
  672.              It gets put back at the proper place
  673.              when the BIND_EXPR is expanded.  */
  674.               delete_block ($3);
  675.             }
  676.           else
  677.             $$ = $3;
  678.         }
  679.     | primary '(' exprlist ')'   %prec '.'
  680.         { $$ = build_function_call ($1, $3); }
  681.     | primary '[' expr ']'   %prec '.'
  682.         { $$ = build_array_ref ($1, $3); }
  683.     | primary '.' identifier
  684.         {
  685.             $$ = build_component_ref ($1, $3);
  686.         }
  687.     | primary POINTSAT identifier
  688.         {
  689.                   tree expr = build_indirect_ref ($1, "->");
  690.  
  691.                     $$ = build_component_ref (expr, $3);
  692.         }
  693.     | primary PLUSPLUS
  694.         { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
  695.     | primary MINUSMINUS
  696.         { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
  697.     ;
  698.  
  699. /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
  700. string:
  701.       STRING
  702.     | string STRING
  703.         { $$ = chainon ($1, $2); }
  704.     ;
  705.  
  706.  
  707. xdecls:
  708.     /* empty */
  709.     | datadecls
  710.     | datadecls ELLIPSIS
  711.         /* ... is used here to indicate a varargs function.  */
  712.         { c_mark_varargs ();
  713.           if (pedantic)
  714.             pedwarn ("ANSI C does not permit use of `varargs.h'"); }
  715.     ;
  716.  
  717. /* The following are analogous to lineno_decl, decls and decl
  718.    except that they do not allow nested functions.
  719.    They are used for old-style parm decls.  */
  720. lineno_datadecl:
  721.       save_filename save_lineno datadecl
  722.         { }
  723.     ;
  724.  
  725. datadecls:
  726.     lineno_datadecl
  727.     | errstmt
  728.     | datadecls lineno_datadecl
  729.     | lineno_datadecl errstmt
  730.     ;
  731.  
  732. datadecl:
  733.     typed_declspecs setspecs initdecls ';'
  734.         { current_declspecs = TREE_VALUE (declspec_stack);
  735.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  736.           declspec_stack = TREE_CHAIN (declspec_stack);
  737.           resume_momentary ($2); }
  738.     | declmods setspecs notype_initdecls ';'
  739.         { current_declspecs = TREE_VALUE (declspec_stack);    
  740.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  741.           declspec_stack = TREE_CHAIN (declspec_stack);
  742.           resume_momentary ($2); }
  743.     | typed_declspecs ';'
  744.         { shadow_tag_warned ($1, 1);
  745.           pedwarn ("empty declaration"); }
  746.     | declmods ';'
  747.         { pedwarn ("empty declaration"); }
  748.     ;
  749.  
  750. /* This combination which saves a lineno before a decl
  751.    is the normal thing to use, rather than decl itself.
  752.    This is to avoid shift/reduce conflicts in contexts
  753.    where statement labels are allowed.  */
  754. lineno_decl:
  755.       save_filename save_lineno decl
  756.         { }
  757.     ;
  758.  
  759. decls:
  760.     lineno_decl
  761.     | errstmt
  762.     | decls lineno_decl
  763.     | lineno_decl errstmt
  764.     ;
  765.  
  766. /* records the type and storage class specs to use for processing
  767.    the declarators that follow.
  768.    Maintains a stack of outer-level values of current_declspecs,
  769.    for the sake of parm declarations nested in function declarators.  */
  770. setspecs: /* empty */
  771.         { $$ = suspend_momentary ();
  772.           pending_xref_error ();
  773.           declspec_stack = tree_cons (prefix_attributes,
  774.                           current_declspecs,
  775.                           declspec_stack);
  776.           current_declspecs = $<ttype>0; 
  777.           prefix_attributes = NULL_TREE; }
  778.     ;
  779.  
  780. setattrs: /* empty */
  781.         { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
  782.     ;
  783.  
  784. decl:
  785.     typed_declspecs setspecs initdecls ';'
  786.         { current_declspecs = TREE_VALUE (declspec_stack);
  787.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  788.           declspec_stack = TREE_CHAIN (declspec_stack);
  789.           resume_momentary ($2); }
  790.     | declmods setspecs notype_initdecls ';'
  791.         { current_declspecs = TREE_VALUE (declspec_stack);
  792.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  793.           declspec_stack = TREE_CHAIN (declspec_stack);
  794.           resume_momentary ($2); }
  795.     | typed_declspecs setspecs nested_function
  796.         { current_declspecs = TREE_VALUE (declspec_stack);
  797.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  798.           declspec_stack = TREE_CHAIN (declspec_stack);
  799.           resume_momentary ($2); }
  800.     | declmods setspecs notype_nested_function
  801.         { current_declspecs = TREE_VALUE (declspec_stack);
  802.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  803.           declspec_stack = TREE_CHAIN (declspec_stack);
  804.           resume_momentary ($2); }
  805.     | typed_declspecs ';'
  806.         { shadow_tag ($1); }
  807.     | declmods ';'
  808.         { pedwarn ("empty declaration"); }
  809.     ;
  810.  
  811. /* Declspecs which contain at least one type specifier or typedef name.
  812.    (Just `const' or `volatile' is not enough.)
  813.    A typedef'd name following these is taken as a name to be declared.  */
  814.  
  815. typed_declspecs:
  816.       typespec reserved_declspecs
  817.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  818.     | declmods typespec reserved_declspecs
  819.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  820.     ;
  821.  
  822. reserved_declspecs:  /* empty */
  823.         { $$ = NULL_TREE; }
  824.     | reserved_declspecs typespecqual_reserved
  825.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  826.     | reserved_declspecs SCSPEC
  827.         { if (extra_warnings)
  828.             warning ("`%s' is not at beginning of declaration",
  829.                  IDENTIFIER_POINTER ($2));
  830.           $$ = tree_cons (NULL_TREE, $2, $1); }
  831.     ;
  832.  
  833. /* List of just storage classes and type modifiers.
  834.    A declaration can start with just this, but then it cannot be used
  835.    to redeclare a typedef-name.  */
  836.  
  837. declmods:
  838.       TYPE_QUAL
  839.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  840.           TREE_STATIC ($$) = 1; }
  841.     | SCSPEC
  842.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  843.     | declmods TYPE_QUAL
  844.         { $$ = tree_cons (NULL_TREE, $2, $1);
  845.           TREE_STATIC ($$) = 1; }
  846.     | declmods SCSPEC
  847.         { if (extra_warnings && TREE_STATIC ($1))
  848.             warning ("`%s' is not at beginning of declaration",
  849.                  IDENTIFIER_POINTER ($2));
  850.           $$ = tree_cons (NULL_TREE, $2, $1);
  851.           TREE_STATIC ($$) = TREE_STATIC ($1); }
  852.     ;
  853.  
  854.  
  855. /* Used instead of declspecs where storage classes are not allowed
  856.    (that is, for typenames and structure components).
  857.    Don't accept a typedef-name if anything but a modifier precedes it.  */
  858.  
  859. typed_typespecs:
  860.       typespec reserved_typespecquals
  861.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  862.     | nonempty_type_quals typespec reserved_typespecquals
  863.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  864.     ;
  865.  
  866. reserved_typespecquals:  /* empty */
  867.         { $$ = NULL_TREE; }
  868.     | reserved_typespecquals typespecqual_reserved
  869.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  870.     ;
  871.  
  872. /* A typespec (but not a type qualifier).
  873.    Once we have seen one of these in a declaration,
  874.    if a typedef name appears then it is being redeclared.  */
  875.  
  876. typespec: TYPESPEC
  877.     | structsp
  878.     | TYPENAME
  879.         { /* For a typedef name, record the meaning, not the name.
  880.              In case of `foo foo, bar;'.  */
  881.           $$ = lookup_name ($1); }
  882.     | TYPEOF '(' expr ')'
  883.         { $$ = TREE_TYPE ($3); }
  884.     | TYPEOF '(' typename ')'
  885.         { $$ = groktypename ($3); }
  886.     ;
  887.  
  888. /* A typespec that is a reserved word, or a type qualifier.  */
  889.  
  890. typespecqual_reserved: TYPESPEC
  891.     | TYPE_QUAL
  892.     | structsp
  893.     ;
  894.  
  895. initdecls:
  896.     initdcl
  897.     | initdecls ',' initdcl
  898.     ;
  899.  
  900. notype_initdecls:
  901.     notype_initdcl
  902.     | notype_initdecls ',' initdcl
  903.     ;
  904.  
  905. maybeasm:
  906.       /* empty */
  907.         { $$ = NULL_TREE; }
  908.     | ASM_KEYWORD '(' string ')'
  909.         { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
  910.           $$ = $3;
  911.         }
  912.     ;
  913.  
  914. initdcl:
  915.       declarator maybeasm maybe_attribute '='
  916.         { $<ttype>$ = start_decl ($1, current_declspecs, 1,
  917.                       $3, prefix_attributes);
  918.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  919.       init
  920. /* Note how the declaration of the variable is in effect while its init is parsed! */
  921.         { finish_init ();
  922.           finish_decl ($<ttype>5, $6, $2); }
  923.     | declarator maybeasm maybe_attribute
  924.         { tree d = start_decl ($1, current_declspecs, 0,
  925.                        $3, prefix_attributes);
  926.           finish_decl (d, NULL_TREE, $2); 
  927.                 }
  928.     ;
  929.  
  930. notype_initdcl:
  931.       notype_declarator maybeasm maybe_attribute '='
  932.         { $<ttype>$ = start_decl ($1, current_declspecs, 1,
  933.                       $3, prefix_attributes);
  934.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  935.       init
  936. /* Note how the declaration of the variable is in effect while its init is parsed! */
  937.         { finish_init ();
  938.           decl_attributes ($<ttype>5, $3, prefix_attributes);
  939.           finish_decl ($<ttype>5, $6, $2); }
  940.     | notype_declarator maybeasm maybe_attribute
  941.         { tree d = start_decl ($1, current_declspecs, 0,
  942.                        $3, prefix_attributes);
  943.           finish_decl (d, NULL_TREE, $2); }
  944.     ;
  945. /* the * rules are dummies to accept the Apollo extended syntax
  946.    so that the header files compile. */
  947. maybe_attribute:
  948.       /* empty */
  949.           { $$ = NULL_TREE; }
  950.     | attributes
  951.         { $$ = $1; }
  952.     ;
  953.  
  954. attributes:
  955.       attribute
  956.         { $$ = $1; }
  957.     | attributes attribute
  958.         { $$ = chainon ($1, $2); }
  959.     ;
  960.  
  961. attribute:
  962.       ATTRIBUTE '(' '(' attribute_list ')' ')'
  963.         { $$ = $4; }
  964.     ;
  965.  
  966. attribute_list:
  967.       attrib
  968.         { $$ = $1; }
  969.     | attribute_list ',' attrib
  970.         { $$ = chainon ($1, $3); }
  971.     ;
  972.  
  973. attrib:
  974.     /* empty */
  975.         { $$ = NULL_TREE; }
  976.     | any_word
  977.         { $$ = build_tree_list ($1, NULL_TREE); }
  978.     | any_word '(' IDENTIFIER ')'
  979.         { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
  980.     | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
  981.         { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
  982.     | any_word '(' exprlist ')'
  983.         { $$ = build_tree_list ($1, $3); }
  984.     ;
  985.  
  986. /* This still leaves out most reserved keywords,
  987.    shouldn't we include them?  */
  988.  
  989. any_word:
  990.       identifier
  991.     | SCSPEC
  992.     | TYPESPEC
  993.     | TYPE_QUAL
  994.     ;
  995.  
  996. /* Initializers.  `init' is the entry point.  */
  997.  
  998. init:
  999.     expr_no_commas
  1000.     | '{'
  1001.         { really_start_incremental_init (NULL_TREE);
  1002.           /* Note that the call to clear_momentary
  1003.              is in process_init_element.  */
  1004.           push_momentary (); }
  1005.       initlist_maybe_comma '}'
  1006.         { $$ = pop_init_level (0);
  1007.           if ($$ == error_mark_node
  1008.               && ! (yychar == STRING || yychar == CONSTANT))
  1009.             pop_momentary ();
  1010.           else
  1011.             pop_momentary_nofree (); }
  1012.  
  1013.     | error
  1014.         { $$ = error_mark_node; }
  1015.     ;
  1016.  
  1017. /* `initlist_maybe_comma' is the guts of an initializer in braces.  */
  1018. initlist_maybe_comma:
  1019.       /* empty */
  1020.         { if (pedantic)
  1021.             pedwarn ("ANSI C forbids empty initializer braces"); }
  1022.     | initlist1 maybecomma
  1023.     ;
  1024.  
  1025. initlist1:
  1026.       initelt
  1027.     | initlist1 ',' initelt
  1028.     ;
  1029.  
  1030. /* `initelt' is a single element of an initializer.
  1031.    It may use braces.  */
  1032. initelt:
  1033.     expr_no_commas
  1034.         { process_init_element ($1); }
  1035.     | '{' 
  1036.         { push_init_level (0); }
  1037.       initlist_maybe_comma '}'
  1038.         { process_init_element (pop_init_level (0)); }
  1039.     | error
  1040.     /* These are for labeled elements.  The syntax for an array element
  1041.        initializer conflicts with the syntax for an Objective-C message,
  1042.        so don't include these productions in the Objective-C grammar.  */
  1043.     | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
  1044.         { set_init_index ($2, $4); }
  1045.       initelt
  1046.     | '[' expr_no_commas ']' '='
  1047.         { set_init_index ($2, NULL_TREE); }
  1048.       initelt
  1049.     | '[' expr_no_commas ']'
  1050.         { set_init_index ($2, NULL_TREE); }
  1051.       initelt
  1052.     | identifier ':'
  1053.         { set_init_label ($1); }
  1054.       initelt
  1055.     | '.' identifier '='
  1056.         { set_init_label ($2); }
  1057.       initelt
  1058.     ;
  1059.  
  1060. nested_function:
  1061.       declarator
  1062.         { push_c_function_context ();
  1063.           if (! start_function (current_declspecs, $1,
  1064.                     prefix_attributes, NULL_TREE, 1))
  1065.             {
  1066.               pop_c_function_context ();
  1067.               YYERROR1;
  1068.             }
  1069.           reinit_parse_for_function (); }
  1070.        xdecls
  1071.         { store_parm_decls (); }
  1072. /* This used to use compstmt_or_error.
  1073.    That caused a bug with input `f(g) int g {}',
  1074.    where the use of YYERROR1 above caused an error
  1075.    which then was handled by compstmt_or_error.
  1076.    There followed a repeated execution of that same rule,
  1077.    which called YYERROR1 again, and so on.  */
  1078.       compstmt
  1079.         { finish_function (1);
  1080.           pop_c_function_context (); }
  1081.     ;
  1082.  
  1083. notype_nested_function:
  1084.       notype_declarator
  1085.         { push_c_function_context ();
  1086.           if (! start_function (current_declspecs, $1,
  1087.                     prefix_attributes, NULL_TREE, 1))
  1088.             {
  1089.               pop_c_function_context ();
  1090.               YYERROR1;
  1091.             }
  1092.           reinit_parse_for_function (); }
  1093.       xdecls
  1094.         { store_parm_decls (); }
  1095. /* This used to use compstmt_or_error.
  1096.    That caused a bug with input `f(g) int g {}',
  1097.    where the use of YYERROR1 above caused an error
  1098.    which then was handled by compstmt_or_error.
  1099.    There followed a repeated execution of that same rule,
  1100.    which called YYERROR1 again, and so on.  */
  1101.       compstmt
  1102.         { finish_function (1);
  1103.           pop_c_function_context (); }
  1104.     ;
  1105.  
  1106. /* Any kind of declarator (thus, all declarators allowed
  1107.    after an explicit typespec).  */
  1108.  
  1109. declarator:
  1110.       after_type_declarator
  1111.     | notype_declarator
  1112.     ;
  1113.  
  1114. /* A declarator that is allowed only after an explicit typespec.  */
  1115.  
  1116. after_type_declarator:
  1117.       '(' after_type_declarator ')'
  1118.         { $$ = $2; }
  1119.     | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
  1120.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1121. /*    | after_type_declarator '(' error ')'  %prec '.'
  1122.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1123.           poplevel (0, 0, 0); }  */
  1124.     | after_type_declarator '[' expr ']'  %prec '.'
  1125.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1126.     | after_type_declarator '[' ']'  %prec '.'
  1127.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1128.     | '*' type_quals after_type_declarator  %prec UNARY
  1129.         { $$ = make_pointer_declarator ($2, $3); }
  1130.     | attributes setattrs after_type_declarator
  1131.         { $$ = $3; }
  1132.     | TYPENAME
  1133.     ;
  1134.  
  1135. /* Kinds of declarator that can appear in a parameter list
  1136.    in addition to notype_declarator.  This is like after_type_declarator
  1137.    but does not allow a typedef name in parentheses as an identifier
  1138.    (because it would conflict with a function with that typedef as arg).  */
  1139.  
  1140. parm_declarator:
  1141.       parm_declarator '(' parmlist_or_identifiers  %prec '.'
  1142.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1143. /*    | parm_declarator '(' error ')'  %prec '.'
  1144.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1145.           poplevel (0, 0, 0); }  */
  1146.     | parm_declarator '[' expr ']'  %prec '.'
  1147.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1148.     | parm_declarator '[' ']'  %prec '.'
  1149.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1150.     | '*' type_quals parm_declarator  %prec UNARY
  1151.         { $$ = make_pointer_declarator ($2, $3); }
  1152.     | attributes setattrs parm_declarator
  1153.         { $$ = $3; }
  1154.     | TYPENAME
  1155.     ;
  1156.  
  1157. /* A declarator allowed whether or not there has been
  1158.    an explicit typespec.  These cannot redeclare a typedef-name.  */
  1159.  
  1160. notype_declarator:
  1161.       notype_declarator '(' parmlist_or_identifiers  %prec '.'
  1162.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1163. /*    | notype_declarator '(' error ')'  %prec '.'
  1164.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1165.           poplevel (0, 0, 0); }  */
  1166.     | '(' notype_declarator ')'
  1167.         { $$ = $2; }
  1168.     | '*' type_quals notype_declarator  %prec UNARY
  1169.         { $$ = make_pointer_declarator ($2, $3); }
  1170.     | notype_declarator '[' expr ']'  %prec '.'
  1171.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1172.     | notype_declarator '[' ']'  %prec '.'
  1173.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1174.     | attributes setattrs notype_declarator
  1175.         { $$ = $3; }
  1176.     | IDENTIFIER
  1177.     ;
  1178.  
  1179. structsp:
  1180.       STRUCT identifier '{'
  1181.         { $$ = start_struct (RECORD_TYPE, $2);
  1182.           /* Start scope of tag before parsing components.  */
  1183.         }
  1184.       component_decl_list '}' maybe_attribute 
  1185.         { $$ = finish_struct ($<ttype>4, $5, $7); }
  1186.     | STRUCT '{' component_decl_list '}' maybe_attribute
  1187.         { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
  1188.                       $3, $5);
  1189.         }
  1190.     | STRUCT identifier
  1191.         { $$ = xref_tag (RECORD_TYPE, $2); }
  1192.     | UNION identifier '{'
  1193.         { $$ = start_struct (UNION_TYPE, $2); }
  1194.       component_decl_list '}' maybe_attribute
  1195.         { $$ = finish_struct ($<ttype>4, $5, $7); }
  1196.     | UNION '{' component_decl_list '}' maybe_attribute
  1197.         { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
  1198.                       $3, $5);
  1199.         }
  1200.     | UNION identifier
  1201.         { $$ = xref_tag (UNION_TYPE, $2); }
  1202.     | ENUM identifier '{'
  1203.         { $<itype>3 = suspend_momentary ();
  1204.           $$ = start_enum ($2); }
  1205.       enumlist maybecomma_warn '}' maybe_attribute
  1206.         { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
  1207.           resume_momentary ($<itype>3); }
  1208.     | ENUM '{'
  1209.         { $<itype>2 = suspend_momentary ();
  1210.           $$ = start_enum (NULL_TREE); }
  1211.       enumlist maybecomma_warn '}' maybe_attribute
  1212.         { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
  1213.           resume_momentary ($<itype>2); }
  1214.     | ENUM identifier
  1215.         { $$ = xref_tag (ENUMERAL_TYPE, $2); }
  1216.     ;
  1217.  
  1218. maybecomma:
  1219.       /* empty */
  1220.     | ','
  1221.     ;
  1222.  
  1223. maybecomma_warn:
  1224.       /* empty */
  1225.     | ','
  1226.         { if (pedantic) pedwarn ("comma at end of enumerator list"); }
  1227.     ;
  1228.  
  1229. component_decl_list:
  1230.       component_decl_list2
  1231.         { $$ = $1; }
  1232.     | component_decl_list2 component_decl
  1233.         { $$ = chainon ($1, $2);
  1234.           pedwarn ("no semicolon at end of struct or union"); }
  1235.     ;
  1236.  
  1237. component_decl_list2:    /* empty */
  1238.         { $$ = NULL_TREE; }
  1239.     | component_decl_list2 component_decl ';'
  1240.         { $$ = chainon ($1, $2); }
  1241.     | component_decl_list2 ';'
  1242.         { if (pedantic)
  1243.             pedwarn ("extra semicolon in struct or union specified"); }
  1244.     ;
  1245.  
  1246. /* There is a shift-reduce conflict here, because `components' may
  1247.    start with a `typename'.  It happens that shifting (the default resolution)
  1248.    does the right thing, because it treats the `typename' as part of
  1249.    a `typed_typespecs'.
  1250.  
  1251.    It is possible that this same technique would allow the distinction
  1252.    between `notype_initdecls' and `initdecls' to be eliminated.
  1253.    But I am being cautious and not trying it.  */
  1254.  
  1255. component_decl:
  1256.       typed_typespecs setspecs components
  1257.         { $$ = $3;
  1258.           current_declspecs = TREE_VALUE (declspec_stack);
  1259.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  1260.           declspec_stack = TREE_CHAIN (declspec_stack);
  1261.           resume_momentary ($2); }
  1262.     | typed_typespecs
  1263.         { if (pedantic)
  1264.             pedwarn ("ANSI C forbids member declarations with no members");
  1265.           shadow_tag($1);
  1266.           $$ = NULL_TREE; }
  1267.     | nonempty_type_quals setspecs components
  1268.         { $$ = $3;
  1269.           current_declspecs = TREE_VALUE (declspec_stack);
  1270.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  1271.           declspec_stack = TREE_CHAIN (declspec_stack);
  1272.           resume_momentary ($2); }
  1273.     | nonempty_type_quals
  1274.         { if (pedantic)
  1275.             pedwarn ("ANSI C forbids member declarations with no members");
  1276.           shadow_tag($1);
  1277.           $$ = NULL_TREE; }
  1278.     | error
  1279.         { $$ = NULL_TREE; }
  1280.     ;
  1281.  
  1282. components:
  1283.       component_declarator
  1284.     | components ',' component_declarator
  1285.         { $$ = chainon ($1, $3); }
  1286.     ;
  1287.  
  1288. component_declarator:
  1289.       save_filename save_lineno declarator maybe_attribute
  1290.         { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
  1291.           decl_attributes ($$, $4, prefix_attributes); }
  1292.     | save_filename save_lineno
  1293.       declarator ':' expr_no_commas maybe_attribute
  1294.         { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
  1295.           decl_attributes ($$, $6, prefix_attributes); }
  1296.     | save_filename save_lineno ':' expr_no_commas maybe_attribute
  1297.         { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
  1298.           decl_attributes ($$, $5, prefix_attributes); }
  1299.     ;
  1300.  
  1301. /* We chain the enumerators in reverse order.
  1302.    They are put in forward order where enumlist is used.
  1303.    (The order used to be significant, but no longer is so.
  1304.    However, we still maintain the order, just to be clean.)  */
  1305.  
  1306. enumlist:
  1307.       enumerator
  1308.     | enumlist ',' enumerator
  1309.         { $$ = chainon ($3, $1); }
  1310.     | error
  1311.         { $$ = error_mark_node; }
  1312.     ;
  1313.  
  1314.  
  1315. enumerator:
  1316.       identifier
  1317.         { $$ = build_enumerator ($1, NULL_TREE); }
  1318.     | identifier '=' expr_no_commas
  1319.         { $$ = build_enumerator ($1, $3); }
  1320.     ;
  1321.  
  1322. typename:
  1323.     typed_typespecs absdcl
  1324.         { $$ = build_tree_list ($1, $2); }
  1325.     | nonempty_type_quals absdcl
  1326.         { $$ = build_tree_list ($1, $2); }
  1327.     ;
  1328.  
  1329. absdcl:   /* an absolute declarator */
  1330.     /* empty */
  1331.         { $$ = NULL_TREE; }
  1332.     | absdcl1
  1333.     ;
  1334.  
  1335. nonempty_type_quals:
  1336.       TYPE_QUAL
  1337.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  1338.     | nonempty_type_quals TYPE_QUAL
  1339.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1340.     ;
  1341.  
  1342. type_quals:
  1343.       /* empty */
  1344.         { $$ = NULL_TREE; }
  1345.     | type_quals TYPE_QUAL
  1346.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1347.     ;
  1348.  
  1349. absdcl1:  /* a nonempty absolute declarator */
  1350.       '(' absdcl1 ')'
  1351.         { $$ = $2; }
  1352.       /* `(typedef)1' is `int'.  */
  1353.     | '*' type_quals absdcl1  %prec UNARY
  1354.         { $$ = make_pointer_declarator ($2, $3); }
  1355.     | '*' type_quals  %prec UNARY
  1356.         { $$ = make_pointer_declarator ($2, NULL_TREE); }
  1357.     | absdcl1 '(' parmlist  %prec '.'
  1358.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1359.     | absdcl1 '[' expr ']'  %prec '.'
  1360.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1361.     | absdcl1 '[' ']'  %prec '.'
  1362.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1363.     | '(' parmlist  %prec '.'
  1364.         { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
  1365.     | '[' expr ']'  %prec '.'
  1366.         { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
  1367.     | '[' ']'  %prec '.'
  1368.         { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
  1369.     | attributes setattrs absdcl1
  1370.         { $$ = $3; }
  1371.     ;
  1372.  
  1373. /* at least one statement, the first of which parses without error.  */
  1374. /* stmts is used only after decls, so an invalid first statement
  1375.    is actually regarded as an invalid decl and part of the decls.  */
  1376.  
  1377. stmts:
  1378.       lineno_stmt_or_label
  1379.     | stmts lineno_stmt_or_label
  1380.     | stmts errstmt
  1381.     ;
  1382.  
  1383. xstmts:
  1384.     /* empty */
  1385.     | stmts
  1386.     ;
  1387.  
  1388. errstmt:  error ';'
  1389.     ;
  1390.  
  1391. pushlevel:  /* empty */
  1392.         { emit_line_note (input_filename, lineno);
  1393.           pushlevel (0);
  1394.           clear_last_expr ();
  1395.           push_momentary ();
  1396.           expand_start_bindings (0);
  1397.         }
  1398.     ;
  1399.  
  1400. /* Read zero or more forward-declarations for labels
  1401.    that nested functions can jump to.  */
  1402. maybe_label_decls:
  1403.       /* empty */
  1404.     | label_decls
  1405.         { if (pedantic)
  1406.             pedwarn ("ANSI C forbids label declarations"); }
  1407.     ;
  1408.  
  1409. label_decls:
  1410.       label_decl
  1411.     | label_decls label_decl
  1412.     ;
  1413.  
  1414. label_decl:
  1415.       LABEL identifiers_or_typenames ';'
  1416.         { tree link;
  1417.           for (link = $2; link; link = TREE_CHAIN (link))
  1418.             {
  1419.               tree label = shadow_label (TREE_VALUE (link));
  1420.               C_DECLARED_LABEL_FLAG (label) = 1;
  1421.               declare_nonlocal_label (label);
  1422.             }
  1423.         }
  1424.     ;
  1425.  
  1426. /* This is the body of a function definition.
  1427.    It causes syntax errors to ignore to the next openbrace.  */
  1428. compstmt_or_error:
  1429.       compstmt
  1430.         {}
  1431.     | error compstmt
  1432.     ;
  1433.  
  1434. compstmt: '{' '}'
  1435.         { $$ = convert (void_type_node, integer_zero_node); }
  1436.     | '{' pushlevel maybe_label_decls decls xstmts '}'
  1437.         { emit_line_note (input_filename, lineno);
  1438.           expand_end_bindings (getdecls (), 1, 0);
  1439.           $$ = poplevel (1, 1, 0);
  1440.           if (yychar == CONSTANT || yychar == STRING)
  1441.             pop_momentary_nofree ();
  1442.           else
  1443.             pop_momentary (); }
  1444.     | '{' pushlevel maybe_label_decls error '}'
  1445.         { emit_line_note (input_filename, lineno);
  1446.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1447.           $$ = poplevel (kept_level_p (), 0, 0);
  1448.           if (yychar == CONSTANT || yychar == STRING)
  1449.             pop_momentary_nofree ();
  1450.           else
  1451.             pop_momentary (); }
  1452.     | '{' pushlevel maybe_label_decls stmts '}'
  1453.         { emit_line_note (input_filename, lineno);
  1454.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1455.           $$ = poplevel (kept_level_p (), 0, 0);
  1456.           if (yychar == CONSTANT || yychar == STRING)
  1457.             pop_momentary_nofree ();
  1458.           else
  1459.             pop_momentary (); }
  1460.     ;
  1461.  
  1462. /* Value is number of statements counted as of the closeparen.  */
  1463. simple_if:
  1464.       if_prefix lineno_labeled_stmt
  1465. /* Make sure expand_end_cond is run once
  1466.    for each call to expand_start_cond.
  1467.    Otherwise a crash is likely.  */
  1468.     | if_prefix error
  1469.     ;
  1470.  
  1471. if_prefix:
  1472.       IF '(' expr ')'
  1473.         { emit_line_note ($<filename>-1, $<lineno>0);
  1474.           expand_start_cond (truthvalue_conversion ($3), 0);
  1475.           $<itype>$ = stmt_count;
  1476.           if_stmt_file = $<filename>-1;
  1477.           if_stmt_line = $<lineno>0;
  1478.           position_after_white_space (); }
  1479.     ;
  1480.  
  1481. /* This is a subroutine of stmt.
  1482.    It is used twice, once for valid DO statements
  1483.    and once for catching errors in parsing the end test.  */
  1484. do_stmt_start:
  1485.       DO
  1486.         { stmt_count++;
  1487.           emit_line_note ($<filename>-1, $<lineno>0);
  1488.           /* See comment in `while' alternative, above.  */
  1489.           emit_nop ();
  1490.           expand_start_loop_continue_elsewhere (1);
  1491.           position_after_white_space (); }
  1492.       lineno_labeled_stmt WHILE
  1493.         { expand_loop_continue_here (); }
  1494.     ;
  1495.  
  1496. save_filename:
  1497.         { $$ = input_filename; }
  1498.     ;
  1499.  
  1500. save_lineno:
  1501.         { $$ = lineno; }
  1502.     ;
  1503.  
  1504. lineno_labeled_stmt:
  1505.       save_filename save_lineno stmt
  1506.         { }
  1507. /*    | save_filename save_lineno error
  1508.         { }
  1509. */
  1510.     | save_filename save_lineno label lineno_labeled_stmt
  1511.         { }
  1512.     ;
  1513.  
  1514. lineno_stmt_or_label:
  1515.       save_filename save_lineno stmt_or_label
  1516.         { }
  1517.     ;
  1518.  
  1519. stmt_or_label:
  1520.       stmt
  1521.     | label
  1522.         { int next;
  1523.           position_after_white_space ();
  1524.           next = getc (finput);
  1525.           ungetc (next, finput);
  1526.           if (pedantic && next == '}')
  1527.             pedwarn ("ANSI C forbids label at end of compound statement");
  1528.         }
  1529.     ;
  1530.  
  1531. /* Parse a single real statement, not including any labels.  */
  1532. stmt:
  1533.       compstmt
  1534.         { stmt_count++; }
  1535.         | all_iter_stmt 
  1536.     | expr ';'
  1537.         { stmt_count++;
  1538.           emit_line_note ($<filename>-1, $<lineno>0);
  1539. /* It appears that this should not be done--that a non-lvalue array
  1540.    shouldn't get an error if the value isn't used.
  1541.    Section 3.2.2.1 says that an array lvalue gets converted to a pointer
  1542.    if it appears as a top-level expression,
  1543.    but says nothing about non-lvalue arrays.  */
  1544. #if 0
  1545.           /* Call default_conversion to get an error
  1546.              on referring to a register array if pedantic.  */
  1547.           if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
  1548.               || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
  1549.             $1 = default_conversion ($1);
  1550. #endif
  1551.           iterator_expand ($1);
  1552.           clear_momentary (); }
  1553.     | simple_if ELSE
  1554.         { expand_start_else ();
  1555.           $<itype>1 = stmt_count;
  1556.           position_after_white_space (); }
  1557.       lineno_labeled_stmt
  1558.         { expand_end_cond ();
  1559.           if (extra_warnings && stmt_count == $<itype>1)
  1560.             warning ("empty body in an else-statement"); }
  1561.     | simple_if %prec IF
  1562.         { expand_end_cond ();
  1563.           /* This warning is here instead of in simple_if, because we
  1564.              do not want a warning if an empty if is followed by an
  1565.              else statement.  Increment stmt_count so we don't
  1566.              give a second error if this is a nested `if'.  */
  1567.           if (extra_warnings && stmt_count++ == $<itype>1)
  1568.             warning_with_file_and_line (if_stmt_file, if_stmt_line,
  1569.                         "empty body in an if-statement"); }
  1570. /* Make sure expand_end_cond is run once
  1571.    for each call to expand_start_cond.
  1572.    Otherwise a crash is likely.  */
  1573.     | simple_if ELSE error
  1574.         { expand_end_cond (); }
  1575.     | WHILE
  1576.         { stmt_count++;
  1577.           emit_line_note ($<filename>-1, $<lineno>0);
  1578.           /* The emit_nop used to come before emit_line_note,
  1579.              but that made the nop seem like part of the preceding line.
  1580.              And that was confusing when the preceding line was
  1581.              inside of an if statement and was not really executed.
  1582.              I think it ought to work to put the nop after the line number.
  1583.              We will see.  --rms, July 15, 1991.  */
  1584.           emit_nop (); }
  1585.       '(' expr ')'
  1586.         { /* Don't start the loop till we have succeeded
  1587.              in parsing the end test.  This is to make sure
  1588.              that we end every loop we start.  */
  1589.           expand_start_loop (1);
  1590.           emit_line_note (input_filename, lineno);
  1591.           expand_exit_loop_if_false (NULL_PTR,
  1592.                          truthvalue_conversion ($4));
  1593.           position_after_white_space (); }
  1594.       lineno_labeled_stmt
  1595.         { expand_end_loop (); }
  1596.     | do_stmt_start
  1597.       '(' expr ')' ';'
  1598.         { emit_line_note (input_filename, lineno);
  1599.           expand_exit_loop_if_false (NULL_PTR,
  1600.                          truthvalue_conversion ($3));
  1601.           expand_end_loop ();
  1602.           clear_momentary (); }
  1603. /* This rule is needed to make sure we end every loop we start.  */
  1604.     | do_stmt_start error
  1605.         { expand_end_loop ();
  1606.           clear_momentary (); }
  1607.     | FOR
  1608.       '(' xexpr ';'
  1609.         { stmt_count++;
  1610.           emit_line_note ($<filename>-1, $<lineno>0);
  1611.           /* See comment in `while' alternative, above.  */
  1612.           emit_nop ();
  1613.           if ($3) c_expand_expr_stmt ($3);
  1614.           /* Next step is to call expand_start_loop_continue_elsewhere,
  1615.              but wait till after we parse the entire for (...).
  1616.              Otherwise, invalid input might cause us to call that
  1617.              fn without calling expand_end_loop.  */
  1618.         }
  1619.       xexpr ';'
  1620.         /* Can't emit now; wait till after expand_start_loop...  */
  1621.         { $<lineno>7 = lineno;
  1622.           $<filename>$ = input_filename; }
  1623.       xexpr ')'
  1624.         { 
  1625.           /* Start the loop.  Doing this after parsing
  1626.              all the expressions ensures we will end the loop.  */
  1627.           expand_start_loop_continue_elsewhere (1);
  1628.           /* Emit the end-test, with a line number.  */
  1629.           emit_line_note ($<filename>8, $<lineno>7);
  1630.           if ($6)
  1631.             expand_exit_loop_if_false (NULL_PTR,
  1632.                            truthvalue_conversion ($6));
  1633.           /* Don't let the tree nodes for $9 be discarded by
  1634.              clear_momentary during the parsing of the next stmt.  */
  1635.           push_momentary ();
  1636.           $<lineno>7 = lineno;
  1637.           $<filename>8 = input_filename;
  1638.           position_after_white_space (); }
  1639.       lineno_labeled_stmt
  1640.         { /* Emit the increment expression, with a line number.  */
  1641.           emit_line_note ($<filename>8, $<lineno>7);
  1642.           expand_loop_continue_here ();
  1643.           if ($9)
  1644.             c_expand_expr_stmt ($9);
  1645.           if (yychar == CONSTANT || yychar == STRING)
  1646.             pop_momentary_nofree ();
  1647.           else
  1648.             pop_momentary ();
  1649.           expand_end_loop (); }
  1650.     | SWITCH '(' expr ')'
  1651.         { stmt_count++;
  1652.           emit_line_note ($<filename>-1, $<lineno>0);
  1653.           c_expand_start_case ($3);
  1654.           /* Don't let the tree nodes for $3 be discarded by
  1655.              clear_momentary during the parsing of the next stmt.  */
  1656.           push_momentary ();
  1657.           position_after_white_space (); }
  1658.       lineno_labeled_stmt
  1659.         { expand_end_case ($3);
  1660.           if (yychar == CONSTANT || yychar == STRING)
  1661.             pop_momentary_nofree ();
  1662.           else
  1663.             pop_momentary (); }
  1664.     | BREAK ';'
  1665.         { stmt_count++;
  1666.           emit_line_note ($<filename>-1, $<lineno>0);
  1667.           if ( ! expand_exit_something ())
  1668.             error ("break statement not within loop or switch"); }
  1669.     | CONTINUE ';'
  1670.         { stmt_count++;
  1671.           emit_line_note ($<filename>-1, $<lineno>0);
  1672.           if (! expand_continue_loop (NULL_PTR))
  1673.             error ("continue statement not within a loop"); }
  1674.     | RETURN ';'
  1675.         { stmt_count++;
  1676.           emit_line_note ($<filename>-1, $<lineno>0);
  1677.           c_expand_return (NULL_TREE); }
  1678.     | RETURN expr ';'
  1679.         { stmt_count++;
  1680.           emit_line_note ($<filename>-1, $<lineno>0);
  1681.           c_expand_return ($2); }
  1682.     | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
  1683.         { stmt_count++;
  1684.           emit_line_note ($<filename>-1, $<lineno>0);
  1685.           STRIP_NOPS ($4);
  1686.           if ((TREE_CODE ($4) == ADDR_EXPR
  1687.                && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
  1688.               || TREE_CODE ($4) == STRING_CST)
  1689.             expand_asm ($4);
  1690.           else
  1691.             error ("argument of `asm' is not a constant string"); }
  1692.     /* This is the case with just output operands.  */
  1693.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
  1694.         { stmt_count++;
  1695.           emit_line_note ($<filename>-1, $<lineno>0);
  1696.           c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
  1697.                      $2 == ridpointers[(int)RID_VOLATILE],
  1698.                      input_filename, lineno); }
  1699.     /* This is the case with input operands as well.  */
  1700.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
  1701.         { stmt_count++;
  1702.           emit_line_note ($<filename>-1, $<lineno>0);
  1703.           c_expand_asm_operands ($4, $6, $8, NULL_TREE,
  1704.                      $2 == ridpointers[(int)RID_VOLATILE],
  1705.                      input_filename, lineno); }
  1706.     /* This is the case with clobbered registers as well.  */
  1707.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
  1708.         asm_operands ':' asm_clobbers ')' ';'
  1709.         { stmt_count++;
  1710.           emit_line_note ($<filename>-1, $<lineno>0);
  1711.           c_expand_asm_operands ($4, $6, $8, $10,
  1712.                      $2 == ridpointers[(int)RID_VOLATILE],
  1713.                      input_filename, lineno); }
  1714.     | GOTO identifier ';'
  1715.         { tree decl;
  1716.           stmt_count++;
  1717.           emit_line_note ($<filename>-1, $<lineno>0);
  1718.           decl = lookup_label ($2);
  1719.           if (decl != 0)
  1720.             {
  1721.               TREE_USED (decl) = 1;
  1722.               expand_goto (decl);
  1723.             }
  1724.         }
  1725.     | GOTO '*' expr ';'
  1726.         { stmt_count++;
  1727.           emit_line_note ($<filename>-1, $<lineno>0);
  1728.           expand_computed_goto (convert (ptr_type_node, $3)); }
  1729.     | ';'
  1730.     ;
  1731.  
  1732. all_iter_stmt:
  1733.       all_iter_stmt_simple
  1734. /*    | all_iter_stmt_with_decl */
  1735.     ;
  1736.  
  1737. all_iter_stmt_simple:
  1738.       FOR '(' primary ')' 
  1739.       {
  1740.         /* The value returned by this action is  */
  1741.         /*      1 if everything is OK */ 
  1742.         /*      0 in case of error or already bound iterator */
  1743.  
  1744.         $<itype>$ = 0;
  1745.         if (TREE_CODE ($3) != VAR_DECL)
  1746.           error ("invalid `for (ITERATOR)' syntax");
  1747.         else if (! ITERATOR_P ($3))
  1748.           error ("`%s' is not an iterator",
  1749.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1750.         else if (ITERATOR_BOUND_P ($3))
  1751.           error ("`for (%s)' inside expansion of same iterator",
  1752.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1753.         else
  1754.           {
  1755.         $<itype>$ = 1;
  1756.         iterator_for_loop_start ($3);
  1757.           }
  1758.       }
  1759.       lineno_labeled_stmt
  1760.       {
  1761.         if ($<itype>5)
  1762.           iterator_for_loop_end ($3);
  1763.       }
  1764.  
  1765. /*  This really should allow any kind of declaration,
  1766.     for generality.  Fix it before turning it back on.
  1767.  
  1768. all_iter_stmt_with_decl:
  1769.       FOR '(' ITERATOR pushlevel setspecs iterator_spec ')' 
  1770.       {
  1771. */        /* The value returned by this action is  */
  1772.         /*      1 if everything is OK */ 
  1773.         /*      0 in case of error or already bound iterator */
  1774. /*
  1775.         iterator_for_loop_start ($6);
  1776.       }
  1777.       lineno_labeled_stmt
  1778.       {
  1779.         iterator_for_loop_end ($6);
  1780.         emit_line_note (input_filename, lineno);
  1781.         expand_end_bindings (getdecls (), 1, 0);
  1782.         $<ttype>$ = poplevel (1, 1, 0);
  1783.         if (yychar == CONSTANT || yychar == STRING)
  1784.           pop_momentary_nofree ();
  1785.         else
  1786.           pop_momentary ();        
  1787.       }
  1788. */
  1789.  
  1790. /* Any kind of label, including jump labels and case labels.
  1791.    ANSI C accepts labels only before statements, but we allow them
  1792.    also at the end of a compound statement.  */
  1793.  
  1794. label:      CASE expr_no_commas ':'
  1795.         { register tree value = check_case_value ($2);
  1796.           register tree label
  1797.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1798.  
  1799.           stmt_count++;
  1800.  
  1801.           if (value != error_mark_node)
  1802.             {
  1803.               tree duplicate;
  1804.               int success = pushcase (value, convert_and_check,
  1805.                           label, &duplicate);
  1806.               if (success == 1)
  1807.             error ("case label not within a switch statement");
  1808.               else if (success == 2)
  1809.             {
  1810.               error ("duplicate case value");
  1811.               error_with_decl (duplicate, "this is the first entry for that value");
  1812.             }
  1813.               else if (success == 3)
  1814.             warning ("case value out of range");
  1815.               else if (success == 5)
  1816.             error ("case label within scope of cleanup or variable array");
  1817.             }
  1818.           position_after_white_space (); }
  1819.     | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
  1820.         { register tree value1 = check_case_value ($2);
  1821.           register tree value2 = check_case_value ($4);
  1822.           register tree label
  1823.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1824.  
  1825.           stmt_count++;
  1826.  
  1827.           if (value1 != error_mark_node && value2 != error_mark_node)
  1828.             {
  1829.               tree duplicate;
  1830.               int success = pushcase_range (value1, value2,
  1831.                             convert_and_check, label,
  1832.                             &duplicate);
  1833.               if (success == 1)
  1834.             error ("case label not within a switch statement");
  1835.               else if (success == 2)
  1836.             {
  1837.               error ("duplicate case value");
  1838.               error_with_decl (duplicate, "this is the first entry for that value");
  1839.             }
  1840.               else if (success == 3)
  1841.             warning ("case value out of range");
  1842.               else if (success == 4)
  1843.             warning ("empty case range");
  1844.               else if (success == 5)
  1845.             error ("case label within scope of cleanup or variable array");
  1846.             }
  1847.           position_after_white_space (); }
  1848.     | DEFAULT ':'
  1849.         {
  1850.           tree duplicate;
  1851.           register tree label
  1852.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1853.           int success = pushcase (NULL_TREE, 0, label, &duplicate);
  1854.           stmt_count++;
  1855.           if (success == 1)
  1856.             error ("default label not within a switch statement");
  1857.           else if (success == 2)
  1858.             {
  1859.               error ("multiple default labels in one switch");
  1860.               error_with_decl (duplicate, "this is the first default label");
  1861.             }
  1862.           position_after_white_space (); }
  1863.     | identifier ':'
  1864.         { tree label = define_label (input_filename, lineno, $1);
  1865.           stmt_count++;
  1866.           emit_nop ();
  1867.           if (label)
  1868.             expand_label (label);
  1869.           position_after_white_space (); }
  1870.     ;
  1871.  
  1872. /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
  1873.  
  1874. maybe_type_qual:
  1875.     /* empty */
  1876.         { emit_line_note (input_filename, lineno);
  1877.           $$ = NULL_TREE; }
  1878.     | TYPE_QUAL
  1879.         { emit_line_note (input_filename, lineno); }
  1880.     ;
  1881.  
  1882. xexpr:
  1883.     /* empty */
  1884.         { $$ = NULL_TREE; }
  1885.     | expr
  1886.     ;
  1887.  
  1888. /* These are the operands other than the first string and colon
  1889.    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
  1890. asm_operands: /* empty */
  1891.         { $$ = NULL_TREE; }
  1892.     | nonnull_asm_operands
  1893.     ;
  1894.  
  1895. nonnull_asm_operands:
  1896.       asm_operand
  1897.     | nonnull_asm_operands ',' asm_operand
  1898.         { $$ = chainon ($1, $3); }
  1899.     ;
  1900.  
  1901. asm_operand:
  1902.       STRING '(' expr ')'
  1903.         { $$ = build_tree_list ($1, $3); }
  1904.     ;
  1905.  
  1906. asm_clobbers:
  1907.       string
  1908.         { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
  1909.     | asm_clobbers ',' string
  1910.         { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
  1911.     ;
  1912.  
  1913. /* This is what appears inside the parens in a function declarator.
  1914.    Its value is a list of ..._TYPE nodes.  */
  1915. parmlist:
  1916.         { pushlevel (0);
  1917.           clear_parm_order ();
  1918.           declare_parm_level (0); }
  1919.       parmlist_1
  1920.         { $$ = $2;
  1921.           parmlist_tags_warning ();
  1922.           poplevel (0, 0, 0); }
  1923.     ;
  1924.  
  1925. parmlist_1:
  1926.       parmlist_2 ')'
  1927.     | parms ';'
  1928.         { tree parm;
  1929.           if (pedantic)
  1930.             pedwarn ("ANSI C forbids forward parameter declarations");
  1931.           /* Mark the forward decls as such.  */
  1932.           for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
  1933.             TREE_ASM_WRITTEN (parm) = 1;
  1934.           clear_parm_order (); }
  1935.       parmlist_1
  1936.         { $$ = $4; }
  1937.     | error ')'
  1938.         { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
  1939.     ;
  1940.  
  1941. /* This is what appears inside the parens in a function declarator.
  1942.    Is value is represented in the format that grokdeclarator expects.  */
  1943. parmlist_2:  /* empty */
  1944.         { $$ = get_parm_info (0); }
  1945.     | ELLIPSIS
  1946.         { $$ = get_parm_info (0);
  1947.           /* Gcc used to allow this as an extension.  However, it does
  1948.              not work for all targets, and thus has been disabled.
  1949.              Also, since func (...) and func () are indistinguishable,
  1950.              it caused problems with the code in expand_builtin which
  1951.              tries to verify that BUILT_IN_NEXT_ARG is being used
  1952.              correctly.  */
  1953.           error ("ANSI C requires a named argument before `...'");
  1954.         }
  1955.     | parms
  1956.         { $$ = get_parm_info (1); }
  1957.     | parms ',' ELLIPSIS
  1958.         { $$ = get_parm_info (0); }
  1959.     ;
  1960.  
  1961. parms:
  1962.     parm
  1963.         { push_parm_decl ($1); }
  1964.     | parms ',' parm
  1965.         { push_parm_decl ($3); }
  1966.     ;
  1967.  
  1968. /* A single parameter declaration or parameter type name,
  1969.    as found in a parmlist.  */
  1970. parm:
  1971.       typed_declspecs setspecs parm_declarator maybe_attribute
  1972.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  1973.                              $3),
  1974.                     build_tree_list (prefix_attributes,
  1975.                              $4));
  1976.           current_declspecs = TREE_VALUE (declspec_stack);
  1977.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  1978.           declspec_stack = TREE_CHAIN (declspec_stack);
  1979.           resume_momentary ($2); }
  1980.     | typed_declspecs setspecs notype_declarator maybe_attribute
  1981.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  1982.                              $3),
  1983.                     build_tree_list (prefix_attributes,
  1984.                              $4)); 
  1985.           current_declspecs = TREE_VALUE (declspec_stack);
  1986.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  1987.           declspec_stack = TREE_CHAIN (declspec_stack);
  1988.           resume_momentary ($2); }
  1989.     | typed_declspecs setspecs absdcl maybe_attribute
  1990.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  1991.                              $3),
  1992.                     build_tree_list (prefix_attributes,
  1993.                              $4));
  1994.           current_declspecs = TREE_VALUE (declspec_stack);
  1995.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  1996.           declspec_stack = TREE_CHAIN (declspec_stack);
  1997.           resume_momentary ($2); }
  1998.     | declmods setspecs notype_declarator maybe_attribute
  1999.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2000.                              $3),
  2001.                     build_tree_list (prefix_attributes,
  2002.                              $4));
  2003.           current_declspecs = TREE_VALUE (declspec_stack);
  2004.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2005.           declspec_stack = TREE_CHAIN (declspec_stack);
  2006.           resume_momentary ($2);  }
  2007.  
  2008.     | declmods setspecs absdcl maybe_attribute
  2009.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2010.                              $3),
  2011.                     build_tree_list (prefix_attributes,
  2012.                              $4));
  2013.           current_declspecs = TREE_VALUE (declspec_stack);
  2014.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2015.           declspec_stack = TREE_CHAIN (declspec_stack);
  2016.           resume_momentary ($2);  }
  2017.     ;
  2018.  
  2019. /* This is used in a function definition
  2020.    where either a parmlist or an identifier list is ok.
  2021.    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
  2022. parmlist_or_identifiers:
  2023.         { pushlevel (0);
  2024.           clear_parm_order ();
  2025.           declare_parm_level (1); }
  2026.       parmlist_or_identifiers_1
  2027.         { $$ = $2;
  2028.           parmlist_tags_warning ();
  2029.           poplevel (0, 0, 0); }
  2030.     ;
  2031.  
  2032. parmlist_or_identifiers_1:
  2033.       parmlist_1
  2034.     | identifiers ')'
  2035.         { tree t;
  2036.           for (t = $1; t; t = TREE_CHAIN (t))
  2037.             if (TREE_VALUE (t) == NULL_TREE)
  2038.               error ("`...' in old-style identifier list");
  2039.           $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
  2040.     ;
  2041.  
  2042. /* A nonempty list of identifiers.  */
  2043. identifiers:
  2044.     IDENTIFIER
  2045.         { $$ = build_tree_list (NULL_TREE, $1); }
  2046.     | identifiers ',' IDENTIFIER
  2047.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2048.     ;
  2049.  
  2050. /* A nonempty list of identifiers, including typenames.  */
  2051. identifiers_or_typenames:
  2052.     identifier
  2053.         { $$ = build_tree_list (NULL_TREE, $1); }
  2054.     | identifiers_or_typenames ',' identifier
  2055.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2056.     ;
  2057.  
  2058. %%
  2059.